PSQL Commands

Connect

If using Command line

 C:\"program files"\postgresql\18\bin\pg_dump -U postgres -d "Movies" -F c -f C:/Postgresqloutput/movies.backup

Change Directory to this

C:\"program files"\postgresql\18\bin


 psql.exe -U postgres -d dvdrental

postgres=# \c Movies

Find Schema
SHOW search_path;


Change Schema
Movies=# SET search_path TO movies;

List databases
\l

List tables
\dt

Get Table design

\d language

Run a query

Movies=# select * from language;

Get query plan

Explain (analyze, buffers) select * from language;

send output to a file

--Windows
copy (SELECT * FROM Country) TO 'C:/Postgresqloutput/results.txt' CSV HEADER;







